package homework;

import java.util.HashMap;
import java.util.Scanner;

public class number3 {
	public static void main(String[] args) {
		//输入
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入一串字符串：");
		String inputstr = sc.next();
		System.out.println("请输入一个数字：");
		int num = sc.nextInt();
		
		char[] arraystr = inputstr.toCharArray();
		
		HashMap<Character, Integer> map = new HashMap<>();
		
		for(char c: arraystr){

			if(map.containsKey(c)){

				Integer value = map.get(c);
				value++;
				map.put(c, value);
			}else{
				map.put(c, 1);
			}
		}
		System.out.println("相同次数的有");
		//对比次数，相同输出
		for (char c : map.keySet()) {
            if (map.get(c) == num) {
                System.out.println(c);
            }
        }
	}
}
